﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Com.Library.DB.Banner
{
    public enum CodeLinkType : byte
    {
        None = 0,
        Self = 1,
        Blank = 2
    }

    public class BannerModel
    {
        public static void Modify(int SeqNo, string ImageURL, string Link, CodeLinkType CodeLinkType, string ManagerName)
        {
            BannerModifyArguments arg = new BannerModifyArguments();
            arg.SeqNo = SeqNo;
            arg.ImageURL = ImageURL;
            arg.Link = Link;
            arg.LinkType = (byte)CodeLinkType;
            arg.ManagerName = ManagerName;

            BannerModify sp = new BannerModify();
            sp.SetArguments(arg);
            sp.ExecuteNonQuery();
        }

        public static void Create(int BannerID, string ImageURL, string Link, CodeLinkType CodeLinkType, string ManagerName)
        {
            BannerCreateArguments arg = new BannerCreateArguments();
            arg.BannerID = BannerID;
            arg.ImageURL = ImageURL;
            arg.Link = Link;
            arg.LinkType = (byte)CodeLinkType;
            arg.ManagerName = ManagerName;

            BannerCreate sp = new BannerCreate();
            sp.SetArguments(arg);
            sp.ExecuteNonQuery();
        }

        public static List<BannerEntity> GetList(int BannerID, int PageNo, byte PageSize)
        {
            List<BannerEntity> ListData = null;
            try
            {
                BannerGetListArguments arg = new BannerGetListArguments();
                arg.codeBannerID = BannerID;
                arg.PageNo = PageNo;
                arg.PageSize = PageSize;
                BannerGetList sp = new BannerGetList();
                sp.SetArguments(arg);

                ListData = sp.Execute();
            }
            catch {
                ListData = new List<BannerEntity>();
            }

            return ListData;
        }

        public static void Remove(int SeqNo)
        {
            BannerRemoveArguments arg = new BannerRemoveArguments();
            arg.n4SeqNo = SeqNo;

            BannerRemove sp = new BannerRemove();
            sp.SetArguments(arg);
            sp.ExecuteNonQuery();
        }
    }
}
